from selenium import webdriver
from time import sleep

from selenium.webdriver import ActionChains, Keys
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()

driver.maximize_window()
driver.get("http://www.baidu.com")

driver.implicitly_wait(10)
driver.find_element(By.NAME,"d4")

actinon = ActionChains(driver)

source = driver.find_element(By.CSS_SELECTOR,".title-content.c-link.c-font-medium.c-line-clamp1")
target = driver.find_element(By.CSS_SELECTOR,"#kw")

actinon.drag_and_drop(source,target).perform()
# actinon.drag_and_drop_by_offset(source,xoffset=100,yoffset=100).perform()
sleep(1)

username = driver.find_element(By.NAME,"wd")

#右键
# actinon.context_click(username).perform()
username.send_keys(Keys.CONTROL,"v")
actinon.double_click(username).perform()
actinon.move_to_element(driver.find_element(By.CSS_SELECTOR,"#su")).perform()

username.send_keys(Keys.BACK_SPACE)
username.send_keys(Keys.CONTROL,"a")
sleep(3)
driver.close()
sleep(1)
driver.quit()


